package com.example.eliminateifelse.ifelse1;

import com.example.eliminateifelse.entity.Cart;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0.0
 * @className: TestIfElse
 * @description:
 * @author: zhangjunfa
 * @date: 2023/1/5 12:03
 */
public class TestIfElse {
    public static void main(String[] args) {
        Map<Long, Integer> items = new HashMap<>();
        int userId = 1;
        //根据用户ID获得用户类型
        String userCategory = getUserCategory(userId);
        //普通用户处理逻辑
        if (userCategory.equals("Normal")) {
            NormalUserCart normalUserCart = new NormalUserCart();
            Cart cart = normalUserCart.process(userId, items);
            System.out.println("Normal:" + cart);
        }
        //VIP用户处理逻辑
        if (userCategory.equals("Vip")) {
            VipUserCart vipUserCart = new VipUserCart();
            Cart cart = vipUserCart.process(userId, items);
            System.out.println("Vip:" + cart);
        }
        //内部用户处理逻辑
        if (userCategory.equals("Internal")) {
            InternalUserCart internalUserCart = new InternalUserCart();
            Cart cart = internalUserCart.process(userId, items);
            System.out.println("Internal:" + cart);
        }
    }

    private static String getUserCategory(int userId) {
        if (userId == 1) {
            return "Vip";
        }
        if (userId == 2) {
            return "Internal";
        }
        return "Normal";
    }


}
